1. Field of the Invention
The present invention relates to databases in distributed computing systems. More specifically, the present invention relates to a method and an apparatus for servicing database requests using a plurality of read-only database servers for servicing read operations and a master database server for servicing both read operations and write operations.
2. Related Art
The rise of the Internet has lead to exponential growth in the number of people who are navigating through web sites on the world wide web. Popular web sites commonly receive millions of visitors each day who generate many millions of page hits.
An application hosting web site can potentially receive far greater volumes of traffic, because an application hosting web site can potentially receive accesses from millions visitors accessing thousands of different applications that can potentially be hosted on the application hosting web site.
In order to support such high volumes of traffic, a web site typically employs multiple web/application servers that operate in parallel to process the traffic through the web site. This allows the capacity of the web site to be increased by simply increasing the number of web/application servers that are processing the traffic. In fact, some web sites presently employ hundreds of web servers that operate in parallel to process the traffic.
Unfortunately, throughput cannot similarly be increased for accesses to database servers. Web servers typically access a single database server to retrieve and manipulate data related to transactions conducted through the web site. For example, a web site that performs sales transactions can read data from an inventory database on a database server to determine which items are available to sell, and can record financial transactions into a financial database on the database server. However, adding additional databases servers does not automatically provide more database throughput because data cannot be replicated across multiple database servers without creating consistency problems.
As traffic through web sites continues to increase, the number of web/application servers can be increased. However, the number of database servers cannot be correspondingly increased. Hence, accesses to database servers can become a bottleneck to overall system performance.
In order to remedy this problem, it is possible to partition a database into a number of sections that are distributed between multiple database servers. This solution can work for applications in which different web/application servers access completely unrelated sections of the database. However, if a number of web/application servers concurrently access the same section of the database, they will concurrently access the same database server, which again creates a bottleneck.
What is needed is a method and an apparatus that provides additional database capacity beyond the capabilities of a single database server without creating consistency problems for the database.
One embodiment of the present invention provides a system that speeds up an application by allowing database tables associated with the application to be partitioned across N read-only slave database servers. In this way, each slave database server can process 1/Nth of the workload of the application. Since this processing can take place in parallel, the system can potentially speed up the application by a factor of N. The system services database requests by using a plurality of read-only database servers for servicing read operations and a master database server for servicing both read operations and write operations. This master database server contains an entire database and the plurality of read-only database servers contain local read-only copies of portions of the database. The system operates by receiving a database request from an application server at a read-only database server. If servicing the request involves performing only read operations, the system performs the read operations on a local read-only copy of a portion of the database. If servicing the request involves performing a write operation, the system sends the write operation to the master database server, and allows the master database server to apply the write operation to the database.
In one embodiment of the present invention, the system receives an update from the master database server reflecting changes to the database caused by the write operation. The system applies this update to the local read-only copy of the portion of the database.
In one embodiment of the present invention, after sending the write operation to the master database server, the system invalidates data affected by the write operation within the local read-only copy of the portion of the database.
In one embodiment of the present invention, invalidating the data involves invalidating a table containing the data.
In one embodiment of the present invention, if a data item to be read is not present in the local read-only copy of the portion of the database, the system retrieves the data item from the master database server, and stores the data item in the local read-only copy of the portion of the database.
One embodiment of the present invention provides a system for servicing database requests using a plurality of read-only database servers for servicing read operations and a master database server for servicing both read operations and write operations. In this system, the master database server contains a database and the plurality of read-only database servers contain local read-only portions of the database. The system partitions the database workload data into a plurality of subsets, and then associates the subsets with a plurality of read-only database servers. Next, the system executes an application that processes the database workload on a plurality of application servers that communicate with the plurality of read-only database servers associated with the plurality of subsets. If servicing a request involves performing a write operation, the system sends the write operation from a read-only database server to the master database server, and allows the master database server to apply the, write operation to the database.
In one embodiment of the present invention, the system additionally identifies portions of the database that are associated with an application, and sends the portions of the database to the plurality of read-only database servers associated with the application during system initialization so that requests from the workload will be directed to the plurality of read-only database servers.
In one embodiment of the present invention, partitioning the database workload involves distributing workload data from the master database server to the plurality of read-only database servers at run time.
In one embodiment of the present invention, a given read-only database server only receives a portion of the database workload from associated applications.
In one embodiment of the present invention, executing the application in the plurality of application servers involves executing different instances of the same application on the plurality of application servers. In a variation on this embodiment, the different instances of the same application operate on different portions of the database workload.
Hence, the present invention provides additional database processing capacity in a scalable way that overcomes the capacity limitations of prior architectures that make use of a single database server to service multiple middle-tier application servers. This scaling results from using multiple read-only xe2x80x9cslavexe2x80x9d database servers to perform operations in parallel with the master database server.
Unlike cluster-based architectures, there is no limit to the number of database servers that can operate together in processing an application. Note that the configuration of the present invention is a hierarchical master-slave arrangement, and not peer-to-peer as in a clustered computing system. In one embodiment of the present invention, this master-slave arrangement is built on top of a network of computers coupled together by a very high-bandwidth, low-latency local network. Also note that by using the present invention it is possible to use database servers from many different hardware vendors.
Applications that can be well-partitioned benefit the most from the present invention. An application can be well-partitioned if the data for the application can be partitioned into identifiable subsets for each partition of the application. For example, applications such as customer relationship management (CRM) applications, ecommerce applications, online service applications, network file systems, enterprise resource planning (ERP) applications and hosting applications tend to be well-partitioned.